package kr.hkit.androidcomplete01;

import kr.hkit.androidcomplete01.R;
import kr.hkit.androidcomplete01.ch04.Ch04Main;
import kr.hkit.androidcomplete01.ch05.Ch05Main;
import kr.hkit.androidcomplete01.ch06.Ch06Main;
import kr.hkit.androidcomplete01.ch07.Ch07Main;
import kr.hkit.androidcomplete01.ch08.Ch08Main;
import kr.hkit.androidcomplete01.ch09.Ch09Main;
import kr.hkit.androidcomplete01.ch11.Ch11Main;
import kr.hkit.androidcomplete01.ch12.Ch12Main;
import kr.hkit.androidcomplete01.ch13.Ch13Main;
import kr.hkit.androidcomplete01.ch14.Ch14Main;
import kr.hkit.androidcomplete01.ch15.Ch15Main;
import kr.hkit.androidcomplete01.ch16.Ch16Main;
import kr.hkit.androidcomplete01.ch18.Ch18Main;
import kr.hkit.androidcomplete01.ch19.Ch19Main;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends ListActivity {
	private String[] lists;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		setContentView(R.layout.activity_main);
		
		lists = getResources().getStringArray(R.array.main_list);
		
/*		for(String str:lists){
			Log.d("lists", str); //LogCat에서 로그기록을 확인.. 필터추가해서..log level Debug선택
		}*/
		
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lists);
		//lists 배열에 있는걸 가져와 simple_list+item_1에 답는다..
		setListAdapter(adapter);
	}
	
	//메뉴에 있는 걸 선택..chapter
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id); //position 인덱스.. chapter04는 position 0 id 0  ....
/*		String text = "View v = " + v.toString() + " : position = " + position + ", id = " + id;
		Toast.makeText(this, text, Toast.LENGTH_LONG).show();*/
		Intent intent = null; //Intent에 실행할 정보를 담는다..
		switch(position){
		case 0:
			intent = new Intent(this, Ch04Main.class);
			startActivity(intent);
			break;
		case 1:
			intent = new Intent(this, Ch05Main.class);
			startActivity(intent);
			break;
		case 2:
			intent = new Intent(this, Ch06Main.class);
			startActivity(intent);
			break;
		case 3:
			intent = new Intent(this, Ch07Main.class);
			startActivity(intent);			
			break;
		case 4:
			intent = new Intent(this, Ch08Main.class);
			startActivity(intent);			
			break;
		case 5:
			intent = new Intent(this, Ch09Main.class);
			startActivity(intent);			
			break;
		case 6:
			intent = new Intent(this, Ch11Main.class);
			startActivity(intent);			
			break;
		case 7:
			intent = new Intent(this, Ch12Main.class);
			startActivity(intent);			
			break;
		case 8:
			intent = new Intent(this, Ch13Main.class);
			startActivity(intent);			
			break;
		case 9:
			intent = new Intent(this, Ch14Main.class);
			startActivity(intent);			
			break;
		case 10:
			intent = new Intent(this, Ch15Main.class);
			startActivity(intent);			
			break;
		case 11:
			intent = new Intent(this, Ch16Main.class);
			startActivity(intent);			
			break;
		case 12:
			intent = new Intent(this, Ch18Main.class);
			startActivity(intent);			
			break;
		case 13:
			intent = new Intent(this, Ch19Main.class);
			startActivity(intent);			
			break;
		default:
			Toast.makeText(this, "즐거운 안드로이드", Toast.LENGTH_LONG).show();
			break;
		}
	}
}